﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAL;
using System.Data;

namespace logic
{
    public class recipe
    {
        /// <summary>
        /// 判断菜谱名称是否存在（范围:系统菜谱或者我的菜谱）
        /// 范围有companyId和source决定
        /// </summary>
        /// <example>
        /// 系统菜谱范围条件：companyId=0 and source='1'
        /// 我的菜谱范围条件：companyId=@companyId and source='2'
        /// </example>
        /// <param name="companyId">企业编号</param>
        /// <param name="recipeName">菜谱名称</param>
        /// <param name="source">来源</param>
        /// <returns></returns>
        public static bool isExistsRecipeName(int companyId, String recipeName, String source)
        {
            return Recipe.isExistsRecipeName(companyId,recipeName,source);
        }
        public static int insert(RecipeEntity recipe)
        {
            return Recipe.insert(recipe);
        }
        public static int insert(int companyId,int recipeId,string recipeName,int rcid)
        {
            return Recipe.insert(companyId, recipeId,recipeName,rcid);
        }
        public static void insert(int companyId,int recipeId)
        {
            Recipe.insert(companyId,recipeId);
        }
        // 将用户菜谱转换成系统菜谱
        public static int insertFromDiyToSystem(RecipeEntity cat)
        {
            return Recipe.insertFromDiyToSystem(cat);
        }
        public static void update(RecipeEntity recipe)
        {
            Recipe.update(recipe);
        }

        public static void delete(int recipeId)
        {
            Recipe.delete(recipeId);
        }

        public static RecipeEntity getById(int recipeId)
        {
            return Recipe.getById(recipeId);
        }

        /// <summary>
        /// 根据菜谱编号查询菜谱详细信息和菜谱清单
        /// </summary>
        /// <param name="recipeId">菜谱编号</param>
        /// <returns>DataSet.Tables[0] 表示菜谱详细信息；DataSet.Tables[1] 表示菜谱清单</returns>
        public static DataSet getRecipeItemById(int recipeId)
        {
            return Recipe.getRecipeItemById(recipeId);
        }
        public static DataSet select(string where, string orderby, int pagesize, int pageindex)
        {
            return DAL.DbHelper.ExecuteDataSetPageSize("*", "vw_Recipe_list", where, "recipeId", orderby, pagesize, pageindex);
        }
    }
}